﻿using System;
using System.Text;
using NIIT.SaoBacDau.Aupi.HospitalManagement.Entities;
using NIIT.SaoBacDau.Aupi.HospitalManagement.DataAccess;
using System.Text.RegularExpressions;

namespace NIIT.SaoBacDau.Aupi.HospitalManagement.BusinessLogic
{
    public enum LoginError { NoError,FormatUserName,PasswordIsEmpty,FormatPassword, NotAccount }

    public class BL_Logins
    {
        public static LoginError Login(Obj_Login Ac)
        {
            Regex r = new Regex("^[a-zA-Z0-9._-]{6,30}$");
            if (r.IsMatch(Ac.UserName) == false)
                return LoginError.FormatUserName;
            else if (string.IsNullOrEmpty(Ac.Password))
                return LoginError.PasswordIsEmpty;
            else if (r.IsMatch(Ac.Password)== false)
                return LoginError.FormatPassword;
            else if (DAO_Login.Login(Ac) == false)
                return LoginError.NotAccount;
            else if (DAO_Login.Login(Ac) == true)
                return LoginError.NoError;
            else
                return LoginError.NoError;
        }
        public static Obj_Employee WellComeEmployee(Obj_Login Ac)
        {
            return DAO_Login.ProfileEmployee(Ac);
        }
    }
}
